package com.frcdi.qms.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * 功能描述
 *
 * @author: author
 * @date: 2024年02月29日 17:35
 */
@Configuration
public class AsyncConfig {

    @Bean(name = "asyncTaskExecutor")
    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(2); // 核心线程数，根据实际情况调整
        executor.setMaxPoolSize(5); // 最大线程数，根据实际情况调整
        executor.setQueueCapacity(500); // 队列容量，根据实际情况调整
        executor.setThreadNamePrefix("async-mail-"); // 线程前缀
        executor.initialize();
        return executor;
    }
}
